package com.xy.quartz.config;

import com.xy.quartz.job.JobDemo;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzDemoConfig {

    @Bean
    public JobDetail jobDetail(){
        return JobBuilder.newJob(JobDemo.class).storeDurably().build();
    }
    @Bean
    public Trigger trigger(){
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/3 * * * * ?");
        return TriggerBuilder.newTrigger().forJob(jobDetail()).withSchedule(cronScheduleBuilder).build();
    }
}
